import request from 'src/axios'

/**
 * @description 分页查询部门列表
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const pageDepart = (params: object) => {
  return request.get('/system/department/page', { params })
}

/**
 * @description 查询所有启用部门
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const listDepart = (params?: object) => {
  return request.get('/system/department/list', { params })
}

/**
 * @description 查看部门信息
 * @param { String } id 主键
 * @returns Promise
 */
export const viewDepart = (id: string) => {
  return request.get('/system/department', { params: { id } })
}

/**
 * @description 新增部门
 * @param { Object } data 新增数据
 * @returns Promise
 */
export const saveDepart = (data: object) => {
  return request.post('/system/department', data)
}

/**
 * @description 修改部门
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateDepart = (data: object) => {
  return request.put('/system/department', data)
}

/**
 * @description 删除部门
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const deleteDepart = (ids: Array<string>) => {
  return request.delete('/system/department', { data: ids })
}

/**
 * @description 启用部门
 * @param { String } id 主键
 * @returns Promise
 */
export const enableDepart = (id: string) => {
  return request.put('/system/department/enable', { id })
}

/**
 * @description 禁用部门
 * @param { String } id 主键
 * @returns Promise
 */
export const disableDepart = (id: string) => {
  return request.put('/system/department/disable', { id })
}

/**
 * @description 查询部门授予权限
 * @param { String } id 主键
 * @returns Promise
 */
export const listCheckedPermission = (id: string) => {
  return request.get('/system/department/permission', { params: { id } })
}

/**
 * @description 给部门授予权限
 * @param { Object } data 授权数据
 * @returns Promise
 */
export const grantPermission = (data: object) => {
  return request.post('/system/department/grant/permission', data)
}
